#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/ioctl.h>


#define FIFO_CLEAR 0x1
#define BUFFER_LEN 20 
#define FILE_DEVICE "/dev/globalfifo"

static void signal_handler(int signum)
{
    printf("recive a signal from globamemfifo ,signalnum =%d\n",signum);

}
void main(void)
{
    int fd,oflages;

    fd = open(FILE_DEVICE,O_RDWR,S_IRUSR|S_IWUSR);
    if(fd != -1){
        signal(SIGIO,signal_handler);
        fcntl(fd,F_SETOWN,getpid());
        oflages = fcntl(fd,F_GETFL);
        fcntl(fd,F_SETFL,oflages | FASYNC);
        while(1){          
            sleep(100);
        }
    }else {
        printf("Device open failed\n");
    }
}